package cn.tedu.rabbitmqboot.m5;


import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public TopicExchange logsExchange(){
        //第二个参数持久属性,默认是一个true,如果交换机在服务器已经存在了,则要设置成和服务器一致的,所以写false
        return new TopicExchange("topic_logs",false,false);
    }

    @Autowired
    Producer p;

    @PostConstruct
    public void test() {
        new Thread(() -> p.send()).start();//lambda表达式
    }
}

